<div id="123" v-cloak>
    <el-row :gutter="20" class="no-margin">
        <el-col :span="20">
            <el-form   >
                <el-form-item label=""  label-width="100%">
                </el-form-item>

            </el-form>
        </el-col>
    </el-row>
    <el-form :inline="true" ref="queryForm" :model="queryForm" label-position="right" label-width="120px">
        <el-form-item label=""  class = "transparent">
            <el-select v-model="queryForm.status"  clearable  placeholder="计划状态">
                <el-option  label="未执行" value="未执行"></el-option>
                <el-option  label="已执行" value="已执行"></el-option>
                <el-option  label="废弃" value="废弃"></el-option>
            </el-select>
            <el-form-item label="" prop="filter" label-width="120px">
                <el-input  placeholder="航班号设备名称或编号" v-model="queryForm.filter" auto-complete="off" size="small"></el-input>
            </el-form-item>
            <el-form-item label="" prop="filter" label-width="120px">
                <el-date-picker
                        v-model="queryForm.startDate"
                        type="date"
                        placeholder="开始日期"
                        @change="pickerStartDate"
                        format="yyyy-MM-dd"
                ></el-date-picker>
            </el-form-item>
            <el-form-item label="" prop="filter" label-width="120px">
                <el-date-picker
                        v-model="queryForm.endDate"
                        type="date"
                        placeholder="结束日期"
                        @change="pickerEndDate"
                        format="yyyy-MM-dd"
                ></el-date-picker>
            </el-form-item>

                <!--size="small"-->
            </el-date-picker>
            <el-button type="primary" @click="query()">查询</el-button>
            <el-button  @click="addEqupment()" type="primary"  >添加</el-button>
        </el-form-item>
    </el-form>
    <template>
        <kf-table :url="url" :pks="['xmlId']"ref="table" :title="formTitle" style="min-height:430px" v-on:row-click="selectRow">
            <el-table-column fixed="left"  >
                <template scope="scope">
                    <el-radio v-model="currentIndex" :label="scope.row.id">`</el-radio>
                </template>
            </el-table-column>
            <el-table-column   label="设备名称"  min-width="150">
                <template scope ="scope">
                    <span v-if="!scope.row.flight">{{scope.row.equipmentPo.equipmentName}}</span>
                    <span v-if="scope.row.flight">航空器</span>
                </template>
            </el-table-column>
            <el-table-column   label="设备编号&航班号" min-width="150" >
                <template scope ="scope">
                    <span v-if="!scope.row.flight">{{scope.row.equipmentPo.equipmentNum}}</span>
                    <span v-if="scope.row.flight">{{scope.row.flightInfoPo.flightNum}}</span>
                </template>
            </el-table-column>
            <el-table-column  prop="maintenanceContent" label="保养内容" min-width="150" >
            </el-table-column>
            <el-table-column  label="保养周期" min-width="150">
                <template scope="scope">
                    <span>{{scope.row.cycle}}{{scope.row.unit}}一次</span>
                </template>
            </el-table-column>
            <el-table-column prop="planeDate" label="计划日期" min-width="100">
            </el-table-column>
            <el-table-column prop="actualDate" label="实行日期" min-width="150">
            </el-table-column>
            <el-table-column prop="status" label="状态" min-width="150">
            </el-table-column>
            <el-table-column label="操作" fixed="right" width="270" >
                <template scope="scope" >
                    <el-button type="text" @click="editRow(scope)">编辑</el-button>
                    <!--<el-button type="text" @click="editRM(scope)">保养维修计划</el-button>-->
                    <el-button type="text" @click="deleteMaintenancePlan(scope)">删除</el-button>
                </template>
            </el-table-column>

            <div slot="editForm">
                <el-form :model="formData">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="航空器" label-width="120px" >
                                <el-checkbox v-model="formData.flight"></el-checkbox>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="普通设备" prop="equipmentName" label-width="120px" v-if="!formData.flight">
                                <el-select v-model="formData.equipmentPo.id" filterable placeholder="请选择" >
                                    <el-option
                                            v-for="equip in equipments"
                                            :key="equip.id"
                                            :label="equip.equipmentName+equip.equipmentNum"
                                            :value="equip.id">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="航班" prop="equipmentName" label-width="120px" v-if="formData.flight">
                                <el-select v-model="formData. flightInfoPo.flightInfoId" filterable placeholder="请选择" >
                                    <el-option
                                            v-for="flight in flights"
                                            :key="flight.flightInfoId"
                                            :label="flight.flightNum"
                                            :value="flight.flightInfoId">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="维护周期" prop="cycle" label-width="120px">
                                <el-input v-model="formData.cycle" auto-complete="off" ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="周期单位" prop="unit" label-width="120px">
                                <el-select v-model="formData.unit"  clearable  placeholder="请选择">
                                    <el-option  label="月" value="月"></el-option>
                                    <el-option  label="周" value="周"></el-option>
                                    <el-option  label="日" value="日"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="计划日期" prop="planeDate" label-width="120px">
                                    <el-date-picker
                                            v-model="formData.planeDate"
                                            type="date"
                                            placeholder="生产日期"
                                            @change="pickerPlaneDate"
                                            format="yyyy-MM-dd"
                                    >
                                    </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="计划状态" prop="teamName" label-width="120px">
                                <el-select v-model="formData.status"  placeholder="请选择">
                                    <el-option  label="未执行" value="未执行"></el-option>
                                    <el-option  label="已执行" value="已执行"></el-option>
                                    <el-option  label="废弃" value="废弃"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-form-item label="保养内容" prop="maintenanceContent" label-width="120px">
                            <el-input
                                    type="textarea"
                                    :autosize="{ minRows: 2, maxRows: 4}"
                                    placeholder="请输入内容"
                                    v-model="formData.maintenanceContent">
                            </el-input>
                        </el-form-item>
                    </el-row>
                </el-form>
            </div>
            <template slot="formBtn" >
                <el-button  v-loading="formDateLoading">取 消</el-button>
                <el-button  v-loading="formDateLoading" type="primary" @click="saveEquipment(currentScope)">确 定</el-button>
            </template>
        </kf-table>
        <!--style="z-index:2008"-->
        <kf-sliding-window :visible.sync="slidingWindowVisible" :close-on-click-outside="false" title="维护保养配置"  width="70%" >
            <template slot="append">
            </template>
            <el-collapse v-model="activeNames" @click.stop="handleChange">
                <el-collapse-item class="is-active"  name="1">
                    <template slot="title">
                        <div  @click.stop="handleChange" >保养配置
                            <i @click="addMaintenanceSetting" class="header-icon el-icon-plus" ></i></div>
                    </template>
                    <kf-table
                            ref="maintenanceSetting"
                            :data="currentEquip.maintenancePlanSettings"
                            max-height="250"

                            one-screen

                            layout="total, sizes, prev, pager, next, jumper"

                    >
                        <el-table-column type="selection" fixed="left"></el-table-column>
                        <el-table-column prop="maintenanceContent" label="保养内容">
                        </el-table-column>
                        <el-table-column prop="leastPlaneDate" label="最后一次保养时间">
                        </el-table-column>
                        <el-table-column  label="保养周期">
                            <template scope="scope">
                                <span>{{scope.row.cycle}}{{scope.row.unit}}一次</span>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" fixed="right" width="120">
                            <template scope="scope">
                                <el-button type="text" icon="edit" @click="editMaintenanceSetting(scope)"></el-button>
                                <el-button type="text" icon="delete" @click="deleteMaintenancePlanSetting(scope)"></el-button>

                            </template>
                        </el-table-column>
                    </kf-table>
                </el-collapse-item>
                <el-collapse-item class="is-active"  name="2">
                    <template slot="title">
                        <div  @click.stop="handleChange">维修配置
                            <i class="header-icon el-icon-plus"  @click = addReparePlaneSetting ></i></div>
                    </template>
                    <kf-table
                            ref="repairPlaneSettings"
                            :data="currentEquip.repairPlaneSettings"
                            max-height="250"
                            one-screen
                            layout="total, sizes, prev, pager, next, jumper"

                    >
                        <el-table-column type="selection" fixed="left"></el-table-column>
                        <el-table-column  label="大修周期">
                            <template scope="scope">
                                <span>{{scope.row.overhaulCycle}}{{scope.row.unit}}一次</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="leastedOverhaulDate" label="大修时间">
                        </el-table-column>
                        <el-table-column  label="中修周期">
                            <template scope="scope">
                                <span>{{scope.row.middleCycle}}{{scope.row.unit}}一次</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="middleCycleDate" label="中修时间"></el-table-column>
                        <el-table-column  label="小修周期">
                            <template scope="scope">
                                <span>{{scope.row.minorRepairCycle}}{{scope.row.unit}}一次</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="minorRepairDate" label="小修时间">
                        </el-table-column>
                        <el-table-column label="操作" fixed="right" width="120">
                            <template scope="scope">
                                <el-button type="text" icon="edit" @click="editReparePlaneSetting(scope)"></el-button>
                                <el-button type="text" icon="delete" @click="deleteReparePlanSetting(scope)"></el-button>
                            </template>
                        </el-table-column>
                    </kf-table>

                </el-collapse-item>
            </el-collapse>
            <el-dialog :title="maintenanceFormTitle" :modal="false" :visible.sync="dialogMaintenanceFormVisible">
                <el-form :model="emptyMaintenancePlanSettingForm" >
                    <!--<el-row>-->
                        <!--<el-col :span="8">-->
                            <el-form-item label="维护周期" prop="cycle" label-width="120px">
                                <el-input v-model="emptyMaintenancePlanSettingForm.cycle" auto-complete="off" size="small"></el-input>
                            </el-form-item>
                        <!--</el-col>-->
                        <!--<el-col :span="12">-->
                            <el-form-item label="周期单位" prop="unit" label-width="120px">
                                <el-select v-model="emptyMaintenancePlanSettingForm.unit"  clearable  placeholder="请选择">
                                    <el-option  label="月" value="月"></el-option>
                                    <el-option  label="周" value="周"></el-option>
                                    <el-option  label="日" value="日"></el-option>
                                </el-select>
                            </el-form-item>
                        <!--</el-col>-->
                    <!--</el-row>-->
                    <!--<el-row>-->
                        <!--<el-col :span="8">-->
                            <el-form-item label="最后一次计划时间" prop="leastPlaneDate" label-width="120px">
                                <el-date-picker
                                        v-model="emptyMaintenancePlanSettingForm.leastPlaneDate"
                                        type="date"
                                        placeholder="最后一次计划时间"
                                        @change="pickerLeastPlaneDate"
                                        format="yyyy-MM-dd"
                                ></el-date-picker>
                            </el-form-item>
                        <!--</el-col>-->
                        <!--<el-col :span="12">-->
                            <el-form-item label="保养内容" prop="maintenanceContent" label-width="120px">
                                <el-input
                                        type="textarea"
                                        :autosize="{ minRows: 2, maxRows: 4}"
                                        placeholder="请输入内容"
                                        v-model="emptyMaintenancePlanSettingForm.maintenanceContent">
                                </el-input>
                            </el-form-item>
                        <!--</el-col>-->
                    <!--</el-row>-->
                </el-form>

                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogMaintenanceFormVisible = false">取 消</el-button>
                    <el-button type="primary" @click="confirmAddMaintenanceSetting">确 定</el-button>
                </div>
            </el-dialog>

            <el-dialog :title="repairPlaneTitle" :modal="false" :visible.sync="dialogRepairPlaneSettings">
                <el-form :model="reparePlaneForm" >
                    <el-form-item label="周期单位" prop="unit" label-width="120px">
                        <el-select v-model="reparePlaneForm.unit"  clearable  placeholder="请选择">
                            <el-option  label="月" value="月"></el-option>
                            <el-option  label="周" value="周"></el-option>
                            <el-option  label="日" value="日"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="大修周期" prop="overhaulCycle" label-width="120px">
                        <el-input v-model="reparePlaneForm.overhaulCycle" auto-complete="off" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="中修周期" prop="middleCycle" label-width="120px">
                        <el-input v-model="reparePlaneForm.middleCycle" auto-complete="off" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="小修周期" prop="minorRepairCycle" label-width="120px">
                        <el-input v-model="reparePlaneForm.minorRepairCycle" auto-complete="off" size="small"></el-input>
                    </el-form-item>
                    <el-form-item label="最后一次大修时间" prop="leastedOverhaulDate" label-width="120px">
                        <el-date-picker
                                v-model="reparePlaneForm.leastedOverhaulDate"
                                type="date"
                                placeholder="最后一次大修时间"
                                @change="pickerLeastedOverhaulDate"
                                format="yyyy-MM-dd"
                        ></el-date-picker>
                    </el-form-item>
                    <el-form-item label="最后一次中修时间" prop="middleCycleDate" label-width="120px">
                        <el-date-picker
                                v-model="reparePlaneForm.middleCycleDate"
                                type="date"
                                placeholder="最后一次中修时间"
                                @change="pickerMiddleCycleDate"
                                format="yyyy-MM-dd"
                        ></el-date-picker>
                    </el-form-item>

                    <el-form-item label="最后一次小修时间" prop="minorRepairDate" label-width="120px">
                        <el-date-picker
                                v-model="reparePlaneForm.minorRepairDate"
                                type="date"
                                placeholder="最后一次小修时间"
                                @change="pickerMinorRepairDate"
                                format="yyyy-MM-dd"
                        ></el-date-picker>
                    </el-form-item>
                </el-form>

                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogMaintenanceFormVisible = false">取 消</el-button>
                    <el-button type="primary" @click="confirmAddRepareSettingSetting">确 定</el-button>
                </div>
            </el-dialog>
        </kf-sliding-window>
    </template>
</div>
